package cz.data.domain.standard.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cz.data.common.annotation.DataInner;
import cz.data.common.base.BaseController;
import cz.data.domain.standard.model.entity.DictEntity;
import cz.data.domain.standard.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/inner")
public class InnerController extends BaseController {

    @Autowired
    private DictService dictService;

    @DataInner
    @GetMapping("/dict/type/{id}")
    public List<DictEntity> getDictEntityByDictTypeId(@PathVariable("id") String typeId) {
        QueryWrapper<DictEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(DictEntity::getTypeId, typeId);
        return dictService.list(queryWrapper);
    }

    @DataInner
    @GetMapping("/dict/gbType/{gbTypeCode}")
    public List<DictEntity> getDictEntityByDictGbTypeCode(@PathVariable("gbTypeCode") String gbTypeCode) {
        QueryWrapper<DictEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(DictEntity::getGbTypeCode, gbTypeCode);
        return dictService.list(queryWrapper);
    }
}
